package examples;
import com.jom.OptimizationProblem;

public class Simple 
{
	public static void main(String[] args)
	{
		
		/* Create the optimization problem object */
		OptimizationProblem op = new OptimizationProblem();

		/* Add the decision variables to the problem */
		op.addDecisionVariable("x", true, new int[] { 1 , 1 }, 0 , 10);
		op.addDecisionVariable("y", true, new int[] { 1 , 1 }, 1 , 5);

		/* Sets the objective function */
		op.setObjectiveFunction("maximize", "x");
		
		/* Add the constraints */
  	op.addConstraint("x + y == 10");

		/* Call the solver to solve the problem */
		op.solve("glpk");

		if (!op.solutionIsOptimal ()) throw new RuntimeException ("An optimal solution was not found");
		
		System.out.println("x: " + op.getPrimalSolution("x").toValue());
		System.out.println("y: " + op.getPrimalSolution("y").toValue());
		System.out.println("Average delay obtained: " + op.getOptimalCost());
	}
}


